Skip to content

Conversation

@Saurabh7019
Copy link
Contributor

Closes #6864

@Saurabh7019 Saurabh7019 marked this pull request as ready for review October 13, 2025 18:54
@milanholemans
Copy link
Contributor

Thanks @Saurabh7019! We'll try to review it ASAP!

@milanholemans milanholemans self-assigned this Oct 17, 2025
@milanholemans milanholemans requested a review from Copilot October 17, 2025 17:04
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new sample script to help administrators generate reports on SharePoint Online list alerts across their tenant in preparation for the retirement of this feature. The script provides a comprehensive PowerShell solution to scan all sites and export alert information to CSV format.

Key Changes

  • Adds a PowerShell script that scans all tenant sites for existing SharePoint alerts
  • Generates a detailed CSV report with alert metadata including frequency, users, and target paths
  • Includes proper metadata and documentation for the sample script

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated no comments.

File Description
docs/docs/sample-scripts/spo/list-tenant-alert-usage/index.mdx Main documentation page with PowerShell script for generating tenant-wide alert reports
docs/docs/sample-scripts/spo/list-tenant-alert-usage/assets/sample.json Metadata configuration for the sample script including author info, tags, and references

Copy link
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Script looks really nice @Saurabh7019! I made a few suggestions to make it good to go.
Thanks for the effort!

@milanholemans milanholemans marked this pull request as draft October 17, 2025 17:10
@Saurabh7019 Saurabh7019 marked this pull request as ready for review October 20, 2025 10:12
Copy link
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvements so far, I think still think we have to improve it a little bit further.
Let me know if anything is unclear.

@milanholemans milanholemans marked this pull request as draft November 4, 2025 23:55
@Saurabh7019 Saurabh7019 marked this pull request as ready for review November 9, 2025 19:24
@Saurabh7019
Copy link
Contributor Author

Thank you for great feedback, @milanholemans. I have made the requested changes, can you have another look when you have time?

Copy link
Contributor

@milanholemans milanholemans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks good to go with a few tiny tweaks!

```powershell
$fileExportPath = "Alerts.csv"

function Get-AlertsToResults {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking of it some more, I think the verb Convert fits better here.

Suggested change
function Get-AlertsToResults {
function Convert-AlertsToResults {


try {
# Get deprecated alerts from specific site
$alerts = m365 spo web alert list --webUrl $SiteUrl --output json --query "[?!(Properties[].Key && contains(Properties[].Key, 'ruletitle'))]" | ConvertFrom-Json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of the query parameter, awesome!

Comment on lines 107 to 108
$sites = m365 spo site list --output json | ConvertFrom-Json
$sites = $sites | Where-Object { $_.ArchiveStatus -eq "NotArchived" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this works, I think we can use the query parameter here as well quite easily. This makes it a bit more consistent with the code above.

$webs = m365 spo web list --url $SiteUrl --output json | ConvertFrom-Json
foreach ($web in $webs) {
Write-Host "`tScanning subsite '$($web.Url)'..." -ForegroundColor Gray
$results += Get-DeprecatedAlertsRecursively -SiteUrl $web.Url -SiteTitle $SiteTitle
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we're always passing the title of the site collection to all its subsites.

Suggested change
$results += Get-DeprecatedAlertsRecursively -SiteUrl $web.Url -SiteTitle $SiteTitle
$results += Get-DeprecatedAlertsRecursively -SiteUrl $web.Url -SiteTitle $web.Title

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

@milanholemans milanholemans merged commit d52282d into pnp:main Nov 11, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New sample script: SharePoint Online list alerts retirement report

2 participants